home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_gimp.idb / usr / freeware / share / gimp / 1.2 / scripts / sel-to-anim-img.scm.z / sel-to-anim-img.scm
Text File  |  2002-07-08  |  5KB  |  122 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Selection to AnimationImage
  4. ; This script requires plug-in-gap-layers-run-animfilter (that is part of
  5. ; the gap Plugin-collection, available in the plugin registry)
  6. ;
  7. ; - 26.5.1999 hof: adapted for GIMP 1.1 Plug-in Interfaces
  8. ; - Takes the Current selection and saves it n-times (as multiple layers) in one seperate image.
  9. ;    (base functions taken from Selection to Image ((c) by Adrian Likins adrian@gimp.org)
  10. ; - added number of copies and
  11. ; - optional { BG-FILL | TRANS-FILL }
  12. ; - if there was no selection at begin the selection is cleared at end 
  13. ; - optional call of plug-in-gap-layers-run-animfilter
  14. ;   (to create animation effects by applying any available PDB filter foreach copy
  15. ;    (==layer) of the generated image
  16. ;    with constant or varying values)
  17. ; - if we just copied some layers set the generated brush-image clean at end
  18. ;
  19. ; This program is free software; you can redistribute it and/or modify
  20. ; it under the terms of the GNU General Public License as published by
  21. ; the Free Software Foundation; either version 2 of the License, or
  22. ; (at your option) any later version.
  23. ; This program is distributed in the hope that it will be useful,
  24. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  26. ; GNU General Public License for more details.
  27. ; You should have received a copy of the GNU General Public License
  28. ; along with this program; if not, write to the Free Software
  29. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  30.  
  31.  
  32. (define (script-fu-selection-to-anim-image image drawable copies bgfill filter-all)
  33.   (let* (
  34.          (idx 0)
  35.      (draw-type (car (gimp-drawable-type-with-alpha drawable)))
  36.      (image-type (car (gimp-image-base-type image)))
  37.      (old-bg (car (gimp-palette-get-background))))
  38.  
  39.     (set! selection-bounds (gimp-selection-bounds image))
  40.     (set! select-offset-x (cadr selection-bounds))
  41.     (set! select-offset-y (caddr selection-bounds))
  42.     (set! selection-width (- (cadr (cddr selection-bounds)) select-offset-x))
  43.     (set! selection-height (- (caddr (cddr selection-bounds)) select-offset-y)) 
  44.  
  45.     (gimp-image-undo-disable image)
  46.  
  47.     (if (= (car (gimp-selection-is-empty image)) TRUE)
  48.     (begin
  49.           ; if the layer has no alpha select all
  50.           (if (= (car (gimp-drawable-has-alpha drawable)) FALSE)
  51.              (begin
  52.                 (gimp-selection-all image)
  53.              )
  54.              (begin
  55.                 (gimp-selection-layer-alpha drawable)
  56.              )
  57.           )
  58.       (set! active-selection (car (gimp-selection-save image)))
  59.       (set! from-selection FALSE)
  60.     )
  61.     (begin 
  62.       (set! active-selection (car (gimp-selection-save image)))
  63.       (set! from-selection TRUE)
  64.     )
  65.     )
  66.  
  67.     (gimp-edit-copy drawable)
  68.  
  69.     (set! brush-image (car (gimp-image-new selection-width selection-height image-type)))
  70.  
  71.     (while (< idx copies)
  72.        (set! draw-name (string-append "frame_0" (number->string idx)))
  73.        (set! brush-draw (car (gimp-layer-new brush-image selection-width selection-height draw-type draw-name 100 NORMAL)))
  74.        (gimp-image-add-layer brush-image brush-draw 0)
  75.        (if (= bgfill TRUE)
  76.            (gimp-drawable-fill brush-draw BG-IMAGE-FILL)
  77.            (gimp-drawable-fill brush-draw TRANS-IMAGE-FILL)
  78.        )
  79.        (let ((floating-sel (car (gimp-edit-paste brush-draw FALSE))))
  80.          (gimp-floating-sel-anchor floating-sel)
  81.        )
  82.        (set! idx (+ idx 1))
  83.     )
  84.  
  85.     (if (= from-selection FALSE)
  86.         (gimp-selection-none image)
  87.     )
  88.  
  89.     (gimp-palette-set-background old-bg)
  90.     (gimp-image-undo-enable image)
  91.     (gimp-image-set-active-layer image drawable)
  92.     (gimp-image-clean-all brush-image)
  93.     (gimp-display-new brush-image)
  94.     (gimp-displays-flush))
  95.     (if (= filter-all TRUE)
  96.         ; INTERACTIVE animated call of any other plugin
  97.         ; (drawable and plugin name are dummy parameters
  98.         ; the plug-in to run is selcted by the built in PDB-browserdialog
  99.         ; of plug-in-gap-layers-run-animfilter)
  100.         (plug-in-gap-layers-run-animfilter 0 brush-image brush-draw "plug-in-bend")
  101.     )
  102. )
  103.  
  104. (script-fu-register "script-fu-selection-to-anim-image"
  105.             _"<Image>/Script-Fu/Animators/Selection to AnimImage..."
  106.             "Create a multilayer image from current selection and apply any PDB Filter to all layer-copies"
  107.             "Wolfgang Hofer <hof@gimp.org>"
  108.             "Wolfgang Hofer"
  109.             "2000/11/30"
  110.             "RGB RGBA GRAY GRAYA"
  111.             SF-IMAGE "Image" 0
  112.             SF-DRAWABLE "Drawable" 0
  113.                     SF-ADJUSTMENT _"Number of Copies"           '(10 1 1024 1 10 0 1)
  114.                     SF-TOGGLE     _"Fill with BG Color"         TRUE
  115.                     SF-TOGGLE     _"Anim-Filter for all Copies" TRUE)
  116.  
  117.  
  118.  
  119.